package com.anasoft.os.s4j;

import org.junit.runner.notification.RunListener;

import com.anasoft.os.s4j.annotation.ErrorReporting;
import com.anasoft.os.s4j.annotation.SeleniumSession;
import com.thoughtworks.selenium.Selenium;

/**
 * Encapsulates common Selenium test runner behavior and hooks for its
 * customization.
 * 
 * @see SeleniumTestRunner
 * @see SeleniumSuiteRunner
 * 
 * @author vojtech.szocs
 */
public interface SeleniumRunnerLogic {

    /**
     * Returns a JUnit {@link RunListener} that implements error reporting
     * behavior of Selenium tests.
     * 
     * @param errorConfig Error reporting configuration.
     * @param session Selenium API for executing commands on the current
     *            session.
     * @return {@link RunListener} for handling error reporting behavior.
     */
    RunListener getErrorReportingListener(ErrorReporting errorConfig, Selenium session);

    /**
     * Returns a {@link SeleniumSessionListener listener} that gets notified of
     * events related to the current {@link Selenium} session.
     * <p>
     * Returning <tt>null</tt> value is equivalent to providing no-op listener
     * implementation.
     * 
     * @return {@link SeleniumSessionListener Listener} reacting to session
     *         events or <tt>null</tt>.
     */
    SeleniumSessionListener getSessionListener();

    /**
     * Returns a {@link EmbeddedSeleniumServerListener listener} that gets
     * notified of events related to the embedded Selenium server.
     * <p>
     * Returning <tt>null</tt> value is equivalent to providing no-op listener
     * implementation.
     * 
     * @return {@link EmbeddedSeleniumServerListener Listener} reacting to
     *         server events or <tt>null</tt>.
     */
    EmbeddedSeleniumServerListener getEmbeddedServerListener();

    /**
     * Returns a custom {@link SeleniumInstanceFactory factory} that creates
     * {@link Selenium} session instances.
     * <p>
     * Returning <tt>null</tt> value represents a fallback to default
     * {@link SeleniumSession} configuration.
     * 
     * @return Custom {@link SeleniumInstanceFactory factory} for creating
     *         {@link Selenium} session instances or <tt>null</tt>.
     */
    SeleniumInstanceFactory getSeleniumInstanceFactory();

}
